import { ObjectId } from "mongodb";
import { mongo } from "../mogoConfig";


const db = mongo.db("my_test")
const inventory = db.collection("inventory")
inventory.countDocuments({}, { hint: "_id_" })
    .then(result => {
        console.log("文档总数：", JSON.stringify(result))
        return inventory.countDocuments({ qty: { $gte: 25 } })
    })
    .then(result => {
        console.log("qty>=25的数量：", JSON.stringify(result))
        return inventory.estimatedDocumentCount()
    })
    .then(result => {
        console.log("预估总数：", result)
    })
    .catch(error => {
        console.log(error)
    }).finally(() => {
        mongo.close()
    })

console.log("执行结束")